package com.hust360.percent.pojo;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import java.util.Map;

public abstract class Area implements Serializable {

	public Date getModifydate() {
		return modifydate;
	}

	public void setModifydate(Date modifydate) {
		this.modifydate = modifydate;
	}

	public static final String TABLE = "Area";

	public static final String ID = "id";

	public static final String IMG = "img";

	public static final String TITLE = "title";

	public static final String FROM = "fromDate";

	public static final String DEADLINE = "deadline";

	public static final String MODIFY = "modifydate";

	public static final String CITY_ID = "cityId";

	public static final String TYPE = "type";

	private static final long serialVersionUID = -8384203676559388393L;
	/**
	 * 区域的id
	 */
	public Long id;

	/**
	 * 区域的图片的名字
	 */
	public String img;

	/**
	 * 区域的文本标题
	 */
	public String title;

	/**
	 * 活动起始时间
	 */
	public Date fromDate;

	/**
	 * 活动结束时间
	 */
	public Date deadline;

	/**
	 * 活动修改的时间
	 */
	public Date modifydate;

	/**
	 * 所在城市的id
	 */
	public Long cityId;

	/*
	 * 弃用，通过查询关系表获取区域对应的店铺 店铺的id列表
	 */
	// private List<Long> shopList;

	/**
	 * 店铺商品的类别
	 */
	public Integer type;

	/**
	 * 地点信息纬度
	 */
	public Double longitude;

	public static final String LONGITUDE_COLUMN = "longitude";

	/**
	 * 地点信息纬度
	 */
	public Double latitude;
	public static final String LATITUDE_COLUMN = "latitude";

	/**
	 * 区域名称
	 */
	public String name;
	public static final String NAME = "name";
	public static final String[] COLUMNS = { CITY_ID, DEADLINE, FROM, ID, IMG,
			LATITUDE_COLUMN, LONGITUDE_COLUMN, MODIFY, NAME, TITLE, TYPE };

	/**
	 * 
	 * @return
	 */
	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getImg() {
		return img;
	}

	public void setImg(String img) {
		this.img = img;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Date getDeadline() {
		return deadline;
	}

	public void setDeadline(Date deadline) {
		this.deadline = deadline;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	// public List<Long> getShopList() {
	// return shopList;
	// }

	// public void setShopList(List<Long> shopList) {
	// this.shopList = shopList;
	// }

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((cityId == null) ? 0 : cityId.hashCode());
		result = prime * result
				+ ((deadline == null) ? 0 : deadline.hashCode());
		result = prime * result
				+ ((fromDate == null) ? 0 : fromDate.hashCode());
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((img == null) ? 0 : img.hashCode());
		result = prime * result
				+ ((latitude == null) ? 0 : latitude.hashCode());
		result = prime * result
				+ ((longitude == null) ? 0 : longitude.hashCode());
		result = prime * result
				+ ((modifydate == null) ? 0 : modifydate.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		result = prime * result + ((title == null) ? 0 : title.hashCode());
		result = prime * result + ((type == null) ? 0 : type.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Area other = (Area) obj;
		if (cityId == null) {
			if (other.cityId != null)
				return false;
		} else if (!cityId.equals(other.cityId))
			return false;
		if (deadline == null) {
			if (other.deadline != null)
				return false;
		} else if (!deadline.equals(other.deadline))
			return false;
		if (fromDate == null) {
			if (other.fromDate != null)
				return false;
		} else if (!fromDate.equals(other.fromDate))
			return false;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		if (img == null) {
			if (other.img != null)
				return false;
		} else if (!img.equals(other.img))
			return false;
		if (latitude == null) {
			if (other.latitude != null)
				return false;
		} else if (!latitude.equals(other.latitude))
			return false;
		if (longitude == null) {
			if (other.longitude != null)
				return false;
		} else if (!longitude.equals(other.longitude))
			return false;
		if (modifydate == null) {
			if (other.modifydate != null)
				return false;
		} else if (!modifydate.equals(other.modifydate))
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		if (title == null) {
			if (other.title != null)
				return false;
		} else if (!title.equals(other.title))
			return false;
		if (type == null) {
			if (other.type != null)
				return false;
		} else if (!type.equals(other.type))
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Area [id=" + id + ", img=" + img + ", title=" + title
				+ ", fromDate=" + fromDate + ", deadline=" + deadline
				+ ", modifydate=" + modifydate + ", cityId=" + cityId
				+ ", type=" + type + ", longitude=" + longitude + ", latitude="
				+ latitude + ", name=" + name + "]";
	}

	public Date getFromDate() {
		return fromDate;
	}

	public void setFromDate(Date fromDate) {
		this.fromDate = fromDate;
	}

	public Long getCityId() {
		return cityId;
	}

	public void setCityId(Long cityId) {
		this.cityId = cityId;
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
	}

	public Double getLongitude() {
		return longitude;
	}

	public void setLongitude(Double longitude) {
		this.longitude = longitude;
	}

	public Double getLatitude() {
		return latitude;
	}

	public void setLatitude(Double latitude) {
		this.latitude = latitude;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public abstract List<Shop> getShop();
	
	public interface AreaDAO {

		public Area findById(Long id);

		// public List<Area> findByExample(Area example);
		/**
		 * @param id
		 */
		public List<Area> findWithMap(Map<String, String> map);

		public void deleteById(Long id);

		// public void deleteByExample(Area example);

		public List<Area> findByArgs(String[] columns, String selection,
				String[] selectionArgs, String groupBy, String having,
				String orderBy);

		public void save(Area area);

	}

}
